package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IReceiveOrBackEngineeringOrderView;
import com.cloudsigns.factorymanager2.engineering.IView.ITeamReceiveOrBackEngineeringInstallOrderView;
import com.cloudsigns.factorymanager2.engineering.model.IReceiveOrBackEngineeringOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.ITeamReceiveOrBackEngineeringInstallOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.ReceiveOrBackEngineeringOrderModel;
import com.cloudsigns.factorymanager2.engineering.model.TeamReceiveOrBackEngineeringInstallOrderModel;

/**
 * Created by tony on 2018/4/19.
 */

public class TeamReceiveOrBackEngineeringInstallOrderPresenter {
    private ITeamReceiveOrBackEngineeringInstallOrderView view;
    private ITeamReceiveOrBackEngineeringInstallOrderModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public TeamReceiveOrBackEngineeringInstallOrderPresenter(ITeamReceiveOrBackEngineeringInstallOrderView view) {
        this.view = view;
        this.model = new TeamReceiveOrBackEngineeringInstallOrderModel();
    }

    public void receiveOrbackEngineeringOrder() {


        model.receiveOrbackEngineeringInstallOrder(view.getOrderId(), view.getStatus(), new TeamReceiveOrBackEngineeringInstallOrderModel.OnReceiveOrBackEngineeringInstallOrderListener() {
            @Override
            public void receiveOrderSuccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.receiveOrBackInstallOrderSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.receiveOrBackInstallOrderFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
